#include <iostream>
using namespace std;


int dfs(int x,int y,int w,int h,char *a){
	if(a[y*w+x] == '#'  ||  x < 0  ||  y < 0  ||  x >= w  ||  y >= h)
		return 0;
	int ans=0;
	a[y*w+x] = '#';
	ans += dfs(x+1,y,w,h,a);
	ans += dfs(x-1,y,w,h,a);
	ans += dfs(x,y+1,w,h,a);
	ans += dfs(x,y-1,w,h,a);
	ans++;
	return ans;
}



int main(){
	while(true){
		int w,h;
		cin>>w>>h;
		if(w == 0  &&  h == 0)
			break;
		char a[h][w];
		int x,y;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>a[i][j];
				if(a[i][j] == '@'){
					y = i;
					x = j;
				}
			}
	//		cout<<i<<endl;
		}
		cout<<dfs(x,y,w,h,&a[0][0])<<endl;
	}
	return 0;
}
